//
// Created by xili on 2024/8/7 19:52.
// Go big or go home.
//
#include <vector>
#include <unordered_map>
#include <cstdlib>

using namespace std;

class Solution {
public:
    unordered_map<int, vector<int>> dp;

    Solution(vector<int> &nums) {

        int i = 0;
        for (auto &item: nums) {
            dp[item].push_back(i++);
        }
    }

    int pick(int target) {
        auto v = dp[target];
        return v[rand() % v.size()];
    }
};